package top.itaso.app.room.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

import top.itaso.app.room.entity.UserEntity;
import top.itaso.app.room.entity.WifiScanResultEntity;

/**
 * @Description:
 * @Author: dengfu.su
 * @CreateDate: 2022/1/19
 */
@Dao
public interface WifiScanResultDao {
    @Query("SELECT * FROM wifis")
    LiveData<List<WifiScanResultEntity>> queryAll();

    @Query("SELECT * FROM wifis WHERE _bssid = :bssid")
    WifiScanResultEntity queryMatchBssid(String bssid);

    @Query("SELECT * FROM wifis WHERE _ssid IN (:ssid)")
    List<WifiScanResultEntity> queryAllInSsid(String[] ssid);

    /**
     * OnConflictStrategy.REPLACE：如果有数据冲突（唯一约束值相同），则进行替换，其中只增加部分则以新增值为准
     *
     * @param wifiScanResultEntity
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long insertAll(WifiScanResultEntity wifiScanResultEntity);

    /**
     * OnConflictStrategy.REPLACE：如果有数据冲突（唯一约束值相同），则进行替换，其中只增加部分则以新增值为准
     *
     * @param wifiScanResultEntities
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insertAll(WifiScanResultEntity... wifiScanResultEntities);

    /**
     * OnConflictStrategy.REPLACE：如果有数据冲突（唯一约束值相同），则进行替换，其中只增加部分则以新增值为准
     *
     * @param wifiScanResultEntities
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insertAll(List<WifiScanResultEntity> wifiScanResultEntities);

    @Delete
    int delete(WifiScanResultEntity wifiScanResultEntity);

    @Update
    int update(WifiScanResultEntity wifiScanResultEntity);

}
